package com.jldt.flutter_douyin;

import android.app.Activity;
import android.util.Log;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;

/**
 * FlutterDouyinPlugin
 */
public class FlutterDouyinPlugin implements FlutterPlugin, ActivityAware {

    private Activity activity;
    private FlutterMethodChannel methodChannel;
    private FlutterEventChannel eventChannel;
    private FlutterPluginBinding flutterPluginBinding;

    @Override
    public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {

        Log.e("FlutterDouyinPlugin...", "[完成]");
        this.flutterPluginBinding = flutterPluginBinding;
        methodChannel = FlutterMethodChannel.getInstance();
        eventChannel = FlutterEventChannel.getInstance();


    }

    @Override
    public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {

    }

    @Override
    public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
        Log.e("初始化 activity...", "[完成]");
        activity = binding.getActivity();
        methodChannel.init(activity, flutterPluginBinding.getBinaryMessenger());
        eventChannel.init(flutterPluginBinding);
    }

    @Override
    public void onDetachedFromActivityForConfigChanges() {

    }

    @Override
    public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {

    }

    @Override
    public void onDetachedFromActivity() {

    }
}
